package com.example.provider;

import com.example.api.Order;
import org.springframework.web.bind.annotation.*;

import java.text.MessageFormat;

/**
 * <b><code>NacosController</code></b>
 * <p>
 * Description
 * <p>
 * <b>Create Time:</b> 2021/9/24 10:17.
 *
 * @author qd.yt
 * @version 0.0.1
 * @since demo-openfeign v0.0.1
 */
@RestController
@RequestMapping(value = "/openfeign/provider")
public class NacosController {

    /**
     * URL中携带参数
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public String get(@PathVariable Integer id) throws InterruptedException {
        Thread.sleep(3000);
        return "accept one msg id="+id;
    }

    /**
     * POJO表单传参
     */
    @PostMapping("/order1")
    public Order createOrder1(Order order){
        return order;
    }

    /**
     * 传递JSON数据
     * @param order
     * @return
     */
    @PostMapping("/order2")
    public Order createOrder2(@RequestBody Order order){
        return order;
    }

    /**
     * 普通表单参数
     * 此种方式传参不建议使用，但是也有很多开发在用
     * @param id
     * @param name
     * @return
     */
    @PostMapping("/test2")
    public String test2(String id,String name) {
        return MessageFormat.format("accept on msg id={0}，name={1}",id,name);
    }


}
